#include "mainwindow.h"
#include <QDebug>
#include <QLabel>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    //setWindowFlags(Qt::FramelessWindowHint);
    //设置主窗口大小
    this->setGeometry(0,0,800,600);


    mainWidget = new QWidget(this);
    mainWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    // 设置mainWidget容器的大小和位置
    mainWidget->setGeometry(0, 0, width(), height());
    mainWidget->  setFocusPolicy(Qt::ClickFocus);
    //水平布局
    hLayout = new QHBoxLayout();
    hLayout->setSpacing(0);
    hLayout->setContentsMargins(0,21,0,21);
    mainWidget->setLayout(hLayout);

    //左边view
    informationController = new InformationController();
    informationController->show(hLayout,416);
    //中间
    systemStateController = new SystemStateController();
    systemStateController->show(hLayout,310);
    //右边
    pushBtnController = new PushBtnController();
    pushBtnController->show(hLayout,74);


    //特殊菜单页面 mainWidget
    specialMenuController = new SpecialMenuController(mainWidget);
    //设置页面 mainWidget
    settingsController = new SettingsController(mainWidget);

    correlationFunction();


}
//关联函数(信号与槽)
void MainWindow::correlationFunction()
{
//    //绑定菜单
    connect(pushBtnController,SIGNAL(showMenuView()),this,SLOT(didClickModeBtnFun()));
//    //绑定设置
    connect(pushBtnController,SIGNAL(showSettingView()),this,SLOT(didClickSettingBtnFun()));
}

void MainWindow::didClickModeBtnFun()
{
    qDebug() <<"点击菜单";
    specialMenuController->show();

}

void MainWindow::didClickSettingBtnFun()
{
    qDebug() <<"点击设置";
    settingsController->show();
}
//按键按下事件
void MainWindow::keyPressEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Space)
    {
        informationController->setAccelerateFun();
//        qDebug() << "按下";
    }
}
//按键释放事件
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
    if(event->key() == Qt::Key_Space)
    {
        informationController->setRetardFun();
//        qDebug() << "抬起";
    }
}


MainWindow::~MainWindow()
{
}

